Skip to content

Add token speed widgets (InputSpeed, OutputSpeed, TotalSpeed)#141

Merged
sirmalloc merged 6 commits intosirmalloc:mainfrom
olion500:main
Mar 5, 2026
Merged

Add token speed widgets (InputSpeed, OutputSpeed, TotalSpeed)#141
sirmalloc merged 6 commits intosirmalloc:mainfrom
olion500:main

Conversation

@olion500
Copy link
Contributor

Overview

This PR adds three new widgets that display token throughput (tokens per second) for Claude Code sessions:

  • InputSpeed: Shows input token processing rate
  • OutputSpeed: Shows output token generation rate
  • TotalSpeed: Shows combined token throughput

Motivation

Token speed metrics help users understand Claude's response performance and can be useful for:

  • Monitoring API performance during sessions
  • Identifying slow responses
  • Comparing throughput across different models

Implementation Details

Speed Calculation

Speed is calculated by measuring active processing time - the time between user requests and assistant responses:

activeTime = sum of (assistant response timestamp - user request timestamp) for each pair
speed = totalTokens / activeTime

This approach excludes idle time (user thinking, typing) and gives a more accurate representation of Claude's response throughput.

Note: The measured speed includes tool execution time (file reads, bash commands, etc.), so output speed may appear lower than pure token generation speed.

Configuration Example

{
  "lines": [
    {
      "items": [
        { "type": "InputSpeed", "color": "cyan" },
        { "type": "OutputSpeed", "color": "cyan" },
        { "type": "TotalSpeed", "color": "cyan" }
      ]
    }
  ]
}

Example Output

In: 10.9 t/s | Out: 1.3 t/s | Total: 12.2 t/s

- Add SpeedMetrics type for tracking token throughput
- Implement speed calculation utilities in speed-metrics.ts
- Add InputSpeed, OutputSpeed, TotalSpeed widgets
- Extend jsonl.ts to extract timing data for speed calculation
- Inject speedMetrics into RenderContext for widget access
- Add unit tests for speed widgets
# Conflicts:
#	src/ccstatusline.ts
#	src/types/RenderContext.ts
#	src/utils/jsonl.ts
#	src/utils/widgets.ts
#	src/widgets/index.ts
@sirmalloc
Copy link
Owner

I'm working on reviewing this and adding support for inclusion of subagent transcript parsing for speed calculations.

@sirmalloc sirmalloc merged commit 7ca9534 into sirmalloc:main Mar 5, 2026
@sirmalloc
Copy link
Owner

Publishing shortly in 2.2.0, added configurable windows and support for subagents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants